<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>电影资料维护</title>
    <jsp:include page="/IncludeJS.jsp"></jsp:include>
</head>
<body onload="init();">
<script type="text/javascript">
    function save() {
        document.forms[0].submit();
    }

    function check() {
        if ($("#movieName").val() == "") {
            alert("请输入电影名称");
            $('#movieName').focus();
            return false;
        }

        if ($("#content").val() == "") {
            alert("请输入电影简介");
            $('#content').focus();
            return false;
        }
        return true;
    }

    function back() {
        location.href = "${pageContext.request.contextPath }/movie/list";
    }

    if ("${msg}" != null && "${msg}".length > 0) {
        alert("${msg}");
    }

    function init() {
        var key = $("#id").val();
        if (key == "0") {
            var d = new Date();
            var y = d.getFullYear();
            var m = d.getMonth() + 1;
            var d = d.getDate();
            $("#registerTime").datebox("setValue", y + "-" + m + "-" + d);
        } else {
            var td = $("#registerTime").val();
            if (td != "" && td.substring(0, 1) != '2') {
                td = "20" + td;
                $("#registerTime").datebox("setValue", td.substring(0, 10));
            }
        }
    }
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" BACKGROUND="images/maintitle.jpg">
    <tr>
        <td align="left">
            <a class="easyui-linkbutton" plain="true" icon="icon-undo" href="javascript:void(0);"
               onclick="back();">返回</a>
        </td>
    </tr>
</table>
<form action="${pageContext.request.contextPath }/movie/save" enctype="multipart/form-data" method="post"
      onsubmit="return check();">
    <input type="hidden" name="movieId" id="id" value="${movie.movieId}"/>
    <table cellpadding="0" cellspacing="0" border="0" style="margin: 0 auto" align="left">
        <tr height="30">
            <td align="right" width="130">电影名称</td>
            <td><input type="text" name="movieName" id="movieName" style="width:250px" value="${movie.movieName}"/><font
                    size="2" color="red">*</font></td>
            <td align="right">电影图片</td>
            <td><input type="file" name="file1" id="file1"></td>
            <td rowspan="5" valign="top"><img src="${pageContext.request.contextPath }/${movie.cimg}" width="150"
                                              align="top"></td>
        </tr>
        <tr height="30">
            <td align="right">区域</td>
            <td>
                <select name="movieAreaId" id="movieAreaId" style="width:250px">
                    <c:forEach items="${areaList}" var="v">
                        <c:if test="${movie.movieAreaId==v.areaId}">
                            <option value="${v.areaId}" selected>${v.areaName}</option>
                        </c:if>
                        <c:if test="${movie.movieAreaId!=v.areaId}">
                            <option value="${v.areaId}">${v.areaName}</option>
                        </c:if>
                    </c:forEach>
                </select>
            </td>
            <td align="right">电影类别</td>
            <td>
                <select name="movieTypeId" id="movieTypeId" style="width:250px">
                    <c:forEach items="${movieTypeList}" var="v">
                        <c:if test="${movie.movieTypeId==v.movieTypeId}">
                            <option value="${v.movieTypeId}" selected>${v.movieTypeName}</option>
                        </c:if>
                        <c:if test="${movie.movieTypeId!=v.movieTypeId}">
                            <option value="${v.movieTypeId}">${v.movieTypeName}</option>
                        </c:if>
                    </c:forEach>
                </select>
            </td>

        </tr>
        <tr height="30">
            <td align="right" width="90">年份</td>
            <td>
                <select name="movieYearId" id="movieYearId" style="width:250px">
                    <c:forEach items="${yearList}" var="v">
                        <c:if test="${movie.movieYearId==v.movieYearId}">
                            <option value="${v.movieYearId}" selected>${v.movieYearName}</option>
                        </c:if>
                        <c:if test="${movie.movieYearId!=v.movieYearId}">
                            <option value="${v.movieYearId}">${v.movieYearName}</option>
                        </c:if>
                    </c:forEach>
                </select>
            </td>
            <td align="right" width="90">播放类别</td>
            <td>
                <select name="playType" id="playType" style="width:250px">
                    <option value="1" <c:if test="${movie.playType==1}">selected</c:if>>即将上映</option>
                    <option value="2" <c:if test="${movie.playType==2}">selected</c:if>>正在热映</option>
                    <option value="3" <c:if test="${movie.playType==3}">selected</c:if>>经典影片</option>
                </select>
            </td>
        </tr>
        <tr height="30">
            <td align="right" width="120">排序</td>
            <td><input type="text" name="seq" id="seq" style="width:250px" value="${movie.seq}"/>
                <font size="2" color="red">*</font>
            </td>
            <td align="right" width="120">上线日期</td>
            <td><input type="text" name="registerTime" id="registerTime" style="width:250px" class="easyui-datebox"
                       value="${movie.registerTime}"/></td>
        </tr>
        <tr height="30">
            <td align="right" width="120">是否进口片</td>
            <td><select name="isImported" id="isImported" style="width:250px">
                <option value="0" <c:if test="${movie.isImported == 0}">selected</c:if>>否</option>
                <option value="1" <c:if test="${movie.isImported == 1}">selected</c:if>>是</option>
            </select>
                <font size="2" color="red">*</font>
            </td>
            <td align="right" width="120">电影时长</td>
            <td>
                <input type="text" name="duration" id="duration" value="${movie.duration}"/>
            </td>
        </tr>
        <tr height="30">
            <td align="right" width="90" style="vertical-align: top">电影简介</td>

            <td colspan="3">
                <textarea name="content" id="content" style="width:630px;height:350px">${movie.content}</textarea>
            </td>

        </tr>

        <tr height="30">
            <td>&nbsp;</td>
            <td colspan="3"><input type="submit" value="   保 存   "/></td>
        </tr>
    </table>
</form>
</body>
</html>